package com.jd.nb.common;

import java.io.Serializable;

/**
 * Created by lantianixang1 on 2018/8/8.
 **/
public class RS<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public RS(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public RS() {
    }

    public enum RsCodeEnum {
        //1000,rpc异常; 1001,参数异常; 1002,系统异常
        SUCCESS(1), NO_LOGIN(999), RPC_ERROR(1000), PARAM_ERROR(1001), SYSTEM_ERROR(1002);
        private int code;

        RsCodeEnum(int code) {
            this.code = code;
        }

        public int getValue() {
            return code;
        }
    }

    public boolean isSuccess() {
        return this.code == RsCodeEnum.SUCCESS.getValue();
    }
}
